package com.example.floatingpopulation.common;

import lombok.Data;

@Data
public class Result<S> {
    private static final String SUCCESS_CODE = "200";
    private static final String ERROR_CODE = "-1";

    private String code;
    private Object data;
    private String msg;

    public static Result<String> success(){
        Result<String> result = new Result<String>();
        result.setCode(SUCCESS_CODE);
        return result;
    }

    public static Result<String> success(Object data){
        Result<String> result = new Result<String>();
        result.setCode(SUCCESS_CODE);
        result.setData(data);
        return result;
    }

    public static Result<String> error(String msg){
        Result<String> result = new Result<String>();
        result.setCode(ERROR_CODE);
        result.setMsg(msg);
        return result;
    }

    public static Result<String> error(String code, String msg){
        Result<String> result = new Result<String>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
